package admin.auth.feishu.feign;


import admin.auth.config.FeignConfig;
import admin.auth.feishu.model.req.AppAuth;
import admin.auth.feishu.model.req.CodeAuth;
import admin.common.domain.rsp.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


/**
 * Created by zgb on 2019/10/18.
 */
//不用走网关
@FeignClient(name = "${feishu.apiPlatform.name}", path = "${feishu.apiPlatform.path}", url = "${feishu.apiPlatform.domain}",
        fallback = FeishuFeignClientFallback.class, configuration = FeignConfig.class
)
public interface FeishuFeignClient {

    @PostMapping("${feishu.api.tenantAccessToken.url}")
    R tenantAccessToken(@RequestBody AppAuth appAuth);


    @PostMapping("${feishu.api.appAccessToken.url}")
    R appAccessToken(@RequestBody AppAuth appAuth);


    @PostMapping("${feishu.api.userAccessToken.url}")
    R<UserAccessTokenRsp> userAccessToken(@RequestBody CodeAuth codeAuth, @RequestHeader("Authorization") String authorization);


    @GetMapping("${feishu.api.userInfo.url}")
    R<UserInfoRsp> userInfo();


    @GetMapping("${feishu.api.users.url}/{user_id}")
    R<UsersRsp> users(@PathVariable("user_id") String userId,
                      @RequestParam(value = "department_id_type", required = true) String departmentIdType,
                      @RequestParam(value = "user_id_type", required = true) String userIdType,
                      @RequestHeader("Authorization") String authorization
    );


    @GetMapping("${feishu.api.employees.url}")
    R<EmployeesRsp> employees(@RequestParam(value = "status", required = false) int[] status,
                              @RequestParam(value = "view", required = false) String view,
                              @RequestParam(value = "page_token", required = false) String pageToken,
                              @RequestParam(value = "page_size", required = false) Integer pageSize,
                              @RequestHeader("Authorization") String authorization
    );


}
